package offer;

public class Fanzhuanerchashu226 {

    class Solution {
        public class TreeNode {
            int val;
            TreeNode left;
            TreeNode right;
            TreeNode(int x) { val = x; }
        }

//        public TreeNode invertTree(TreeNode root) {
//            if (root==null)return null;
//            TreeNode tmp = root.left;
//            root.left=invertTree(root.right);
//            root.right=invertTree(tmp);
//            return root;
//        }
        public TreeNode invertTree(TreeNode root) {
            if (root==null)return null;
            TreeNode rightRoot=invertTree(root.left);
            TreeNode leftRoot = invertTree(root.right);

            root.left=leftRoot;
            root.right=rightRoot;

            return root;

        }
    }
}
